package com.demo2do.fms.entity.data.cost;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.demo2do.core.format.PersistentFormat;
import com.demo2do.fms.entity.authority.Organization;
import com.demo2do.fms.entity.data.business.VehicleFeature;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 汽车轮胎费
 * 
 * @author Ysy
 *
 */
@Entity
@Table(name = "TBL_TRUCK_TYRE_FEE")
public class TyreFee {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 费用  */
    private BigDecimal price;
    
    /** 起始公里数 */
    private Integer rangeFrom;
    
    /** 目的公里数  */
    private Integer rangeTo;
    
    /** 所属公司  */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "organization_id", referencedColumnName = "id")
    @JsonIgnore(value =true)
    @PersistentFormat
    private Organization organization;
    
    /** 动力类型  */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "power_type_id", referencedColumnName = "id")
    @JsonIgnore(value =true)
    @PersistentFormat
    private VehicleFeature vehicleFeature;
    
    /** 创建人  */
    private Long creatorId;
    
    /** 创建时间  */
    private Date createDate;
    
    /** 开始时间  */
    private Date startDate;
    
    /** 结束时间  */
    private Date endDate;
    
    @Column(name = "is_disabled")
    private Boolean disabled;
    
    /**
     * 
     * the default constructor
     */
    public TyreFee() {

    }
    
    /**
     * 
     * @param rangeFrom
     * @param rangeTo
     * @param price
     * @param organization
     * @param vehicleFeature
     */
    public TyreFee(Integer rangeFrom,
                   Integer rangeTo,
                   BigDecimal price ,
                   Organization organization ,
                   VehicleFeature vehicleFeature){
        this.rangeFrom = rangeFrom;
        this.rangeTo = rangeTo;
        this.price = price;
        this.organization = organization;
        this.vehicleFeature = vehicleFeature ;
    }
    
    /**
     * 
     * @return
     */
    public TyreFee disabled(){
        this.disabled = true;
        return this;
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public TyreFee operator(Long operator){
        this.creatorId=operator;
        return this;
    }
    
    /**
     * 
     * @return
     */
    public TyreFee init(){
    	this.createDate = new Date();
    	this.disabled = false;
    	this.startDate= new Date();
    	this.endDate = new Date();
    	return this;
    }

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @return the price
	 */
	public BigDecimal getPrice() {
		return price;
	}

	/**
	 * @return the rangeFrom
	 */
	public Integer getRangeFrom() {
		return rangeFrom;
	}

	/**
	 * @return the rangeTo
	 */
	public Integer getRangeTo() {
		return rangeTo;
	}

	/**
	 * @return the organization
	 */
	public Organization getOrganization() {
        return organization;
    }

	/**
	 * @return the vehicleFeature
	 */
	public VehicleFeature getVehicleFeature() {
		return vehicleFeature;
	}

	/**
	 * @return the creatorId
	 */
	public Long getCreatorId() {
		return creatorId;
	}

	/**
	 * @return the createDate
	 */
	public Date getCreateDate() {
		return createDate;
	}

	/**
	 * @return the startDate
	 */
	public Date getStartDate() {
		return startDate;
	}

	/**
	 * @return the endDate
	 */
	public Date getEndDate() {
		return endDate;
	}

	/**
	 * @return the disabled
	 */
	public Boolean getDisabled() {
		return disabled;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @param price the price to set
	 */
	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	/**
	 * @param rangeFrom the rangeFrom to set
	 */
	public void setRangeFrom(Integer rangeFrom) {
		this.rangeFrom = rangeFrom;
	}

	/**
	 * @param rangeTo the rangeTo to set
	 */
	public void setRangeTo(Integer rangeTo) {
		this.rangeTo = rangeTo;
	}

	/**
	 * @param organization the organization to set
	 */
	public void setOrganization(Organization organization) {
        this.organization = organization;
    }

	/**
	 * @param vehicleFeature the vehicleFeature to set
	 */
	public void setVehicleFeature(VehicleFeature vehicleFeature) {
		this.vehicleFeature = vehicleFeature;
	}

	/**
	 * @param creatorId the creatorId to set
	 */
	public void setCreatorId(Long creatorId) {
		this.creatorId = creatorId;
	}

	/**
	 * @param createDate the createDate to set
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	/**
	 * @param startDate the startDate to set
	 */
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	/**
	 * @param endDate the endDate to set
	 */
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	/**
	 * @param disabled the disabled to set
	 */
	public void setDisabled(Boolean disabled) {
		this.disabled = disabled;
	}

}
